package com.starblink.common.feishu.bot.model;


import cn.hutool.json.JSONUtil;
import com.starblink.common.feishu.bot.enums.MsgTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * 富文本消息 具体参考 @see <a href="https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/im-v1/message/create_json">飞书富文本</a>
 * @author 陈青松
 */
@Data
public class PostMsgModel extends MsgModel {

    /**
     * 文本内容对象
     */
    private Post content;

    private PostMsgModel() {
        msg_type = MsgTypeEnum.post;
    }

    /**
     * 创建一个text对象
     *
     * @param post String 富文本内容 具体参考 @see <a href="https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/im-v1/message/create_json">飞书富文本</a>
     * @return
     */
    public static PostMsgModel post(Object post) {
        PostMsgModel textMsgModel = new PostMsgModel();
        textMsgModel.content =new Post((post instanceof String)? JSONUtil.parseObj(post):post);
        return textMsgModel;
    }


    @Data
    @AllArgsConstructor
    public static class Post {
        private Object post;
    }
}
